<template>
	<view class="">
		

		<view class="bg-white"  >
		 <view class=" item  "  v-for="(item,index) in galleryList" @click="openurl('/pages/gallery/detail?id='+item.id)" :key="index" v-if="item.content_data && item.content_data.photo">
			 <image mode="aspectFit" :src="item.content_data.photo[0]+'?imageView2/1/w/400/h/300'"></image>
		 	 <view>{{item.content_data.date}}</view>
			  <view>{{item.content_data.desc}}</view>
		 </view>
		 
		  <view class="clear"></view>
		</view>
		
		 <uni-load-more :status="loadingType"></uni-load-more>
	</view>
</template>

<script>
	import beeApp from '../../beeApp.js';
		import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		 
		},
		data() {
			return {

				userInfo: {},
				 page:1,
				 loading:0,
				loadingType: 'more',
				galleryList: [],
				 


			};
		},
		onShareAppMessage(res) {
			if (res.from === 'button') { // 来自页面内分享按钮
				console.log(res.target)
			}
		},
		onLoad(option) {
			this.material_id = option.id
			// beeApp.alert("yiqwyei");
			// this.getLeastUrls();

			this.load();

		},
		onPullDownRefresh() {
			this.load("reload");
			uni.stopPullDownRefresh();
		},

		methods: {
			//轮播图切换修改背景色
			swiperChange(e) {
				const index = e.detail.current;
				this.swiperCurrent = index;

			},
			openurl(url,type){
				if(type=="switchTab"){
					uni.switchTab({
						url:url
					})
				}else{
					uni.navigateTo({
						url:url
					})
				}
				
			},
			load: function(type) {
				 
				this.getGalleryList(type);
				 
			},
			
			
			getGalleryList(type) {
				var that = this;
				if(type=="reload"){
					that.galleryList=[];
					this.page=1;
					 
					this.loadingType = 'more';
				}
				if (this.loadingType == 'loading' || this.loadingType === 'nomore') {
					return;
				}
				this.loadingType = 'loading';
				beeApp.api(
					'sns/material-list/get', {
						type: 'gallery',
						material_id:this.material_id,
						limit: 10,
						page:this.page,
					},
					function(res) {
						
						if(res.code != 200) {
							 that.loadingType = 'more';
							beeApp.alert(res.msg);
							return;
						}
						// that.galleryList = res.data.list;
						if (res.data.list && res.data.list.length > 0) {
							that.page++;
							that.loadingType = 'more';
							that.galleryList = that.galleryList.concat(res.data.list);
						} else {
							that.loadingType = 'nomore';
						}

					}
				);
			},
			

		}
	};
</script>

<style lang="scss">
	.clear{ }
	.item{ 
		width:50%;  
		float:left; 
		padding:8px;
		image{ height:300upx}
	 
	}

</style>
